#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QWidget, QVBoxLayout, QPushButton, QLabel
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QFont

class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        self.initUI()
        
    def initUI(self):
        # 设置窗口标题和大小
        self.setWindowTitle('PyQt5 桌面应用')
        self.setGeometry(300, 300, 600, 400)
        
        # 创建中央部件
        central_widget = QWidget()
        self.setCentralWidget(central_widget)
        
        # 创建垂直布局
        layout = QVBoxLayout(central_widget)
        
        # 添加标题标签
        title_label = QLabel('欢迎使用 PyQt5 桌面应用')
        title_label.setAlignment(Qt.AlignCenter)
        title_label.setFont(QFont('Arial', 18, QFont.Bold))
        layout.addWidget(title_label)
        
        # 添加说明标签
        info_label = QLabel('这是一个使用PyQt5创建的简单桌面应用示例')
        info_label.setAlignment(Qt.AlignCenter)
        info_label.setFont(QFont('Arial', 12))
        layout.addWidget(info_label)
        
        # 添加按钮
        self.button = QPushButton('点击我')
        self.button.setFixedSize(200, 50)
        self.button.clicked.connect(self.on_button_click)
        layout.addWidget(self.button, alignment=Qt.AlignCenter)
        
        # 添加状态标签
        self.status_label = QLabel('等待操作...')
        self.status_label.setAlignment(Qt.AlignCenter)
        layout.addWidget(self.status_label)
        
        # 设置布局的间距
        layout.setSpacing(20)
        layout.setContentsMargins(30, 30, 30, 30)
        
    def on_button_click(self):
        self.status_label.setText('按钮被点击了！')


def main():
    app = QApplication(sys.argv)
    window = MainWindow()
    window.show()
    sys.exit(app.exec_())


if __name__ == '__main__':
    main()